package com.aliyun.messagemgt.repository;

import com.aliyun.messagemgt.converter.SmsSignConverter;
import com.aliyun.messagemgt.domain.repository.SmsSignRepository;
import com.aliyun.messagemgt.dto.vo.SmsSignVO;
import com.aliyun.messagemgt.entities.SmsSignEntity;
import com.aliyun.messagemgt.repository.mappers.SmsSignMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @Description
 * @Author hzw
 * @Date 2020/12/22 16:58
 * @Version 1.0
 */
@Service
public class SmsSignMybatisRepository implements SmsSignRepository {
    @Autowired
    private SmsSignMapper smsSignMapper;

    @Override
    public List<SmsSignVO> getSmsSigns(Integer templateId) {
        List<SmsSignEntity> smsSignEntityList = smsSignMapper.getSmsSigns(templateId);
        List<SmsSignVO> smsSignVOList = SmsSignConverter.INSTANCE.smsSignEntityList2smsSignVOList(smsSignEntityList);
        return smsSignVOList;
    }

    @Override
    public int insert(SmsSignVO smsSignVo) {
        return smsSignMapper.insert(smsSignVo);
    }

    @Override
    public int updateById(SmsSignVO smsSignVo) {
        return smsSignMapper.updateById(smsSignVo);
    }

    @Override
    public int deleteById(Integer id, String accountInfo) {
        int i = smsSignMapper.deleteById(id, accountInfo);
        return i;
    }

    @Override
    public int findTemplateBySmsSign(Integer smsSignId) {
        return smsSignMapper.findTemplateBySmsSign(smsSignId);
    }

    @Override
    public List<SmsSignVO> findAll() {
        List<SmsSignEntity> smsSignEntities = smsSignMapper.findAll();
        List<SmsSignVO> smsSignVOList = SmsSignConverter.INSTANCE.smsSignEntityList2smsSignVOList(smsSignEntities);
        return smsSignVOList;
    }
}
